﻿<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML dir=ltr XMLNS:MSHelp = "http://msdn.microsoft.com/mshelp" xmlns:ddue = 
"http://ddue.schemas.microsoft.com/authoring/2003/5" xmlns:xlink = 
"http://www.w3.org/1999/xlink" xmlns:tool = "http://www.microsoft.com/tooltip" 
XMLNS:[default] http://ddue.schemas.microsoft.com/authoring/2003/5 = 
"http://ddue.schemas.microsoft.com/authoring/2003/5"><HEAD><TITLE>SimpleWebToken Sample</TITLE>
<META content="text/html; CHARSET=utf-8" http-equiv=Content-Type></META>
<META name=save content=history></META><LINK rel=stylesheet type=text/css 
href="../../../../CommonFiles/Classic.css"></LINK>

<META name=GENERATOR content="MSHTML 8.00.6001.18702"></HEAD>
<BODY>
<DIV id=header>
<TABLE id=topTable width="100%">
  <TBODY>
  <TR id=headerTableRow1>
    <TD align=left><SPAN id=runningHeaderText></SPAN></TD></TR>
  <TR id=headerTableRow2>
    <TD align=left><SPAN id=nsrTitle>SimpleWebToken Sample</SPAN></TD></TR>
  <TR id=headerTableRow3>
    <TD></TD></TR></TBODY></TABLE>
</DIV>
<DIV id=mainSection>
<DIV id=mainBody>
<DIV id=allHistory class=saveHistory onload="loadAll()" 
onsave="saveAll()"></DIV>
<P>This sample demonstrates how to use a simple web token credential to authenticate 
    with the Service Bus.</P>
<P>The sample is similar to the Echo sample, with a few changes. Specifically, this sample adds a 
behavior in the <CODE>ServiceHost</CODE> 
    (service) and <CODE>ChannelFactory</CODE> (client) applications.</P>
<H2 class=heading>Prerequisites</H2>
<DIV id=sectionSection0 class=section><content 
xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
<P xmlns="">If you haven&#39;t already done so, please read the release notes document 
    that explains how to sign up for a Windows Azure account and how to 
    configure your environment. </P>
    </content>
    </DIV>
<H2 class=heading>Service</H2>
<DIV id=sectionSection1 class=section><content 
xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
<P xmlns="">Please refer to the Echo sample for information about how the service is 
    defined and configured.</P>
    <P xmlns="">The service authenticates with the Service Bus using a <b>SimpleWebToken</b> credential. 
        It uses a helper method <CODE>ComputeSimpleWebTokenString(string issuerName, string issuerSecret)</CODE> to compute the string that is 
        expected by <CODE>TransportClientEndpointBehavior</CODE>.</P></content></DIV>
<H2 class=heading>Client</H2>
<DIV id=sectionSection2 class=section><content 
xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
<P xmlns="">Please refer to the Echo sample for information about how the client is 
    defined and configured.</P>
    <P xmlns="">In this sample, both the client and the service use the same credential; therefore, no 
        additional steps are required to grant the client access to listen or to send messages 
        to the service through the Service Bus.&nbsp; By default, a credential is granted with
        <b>Listen, Send, and Manage</b> 
        privileges within its own Service Bus service namespace.&nbsp; If a client is 
        using a different credential than the service, a specific Access Control rule is 
        needed for a client credential to gain <b>Listen, Send or Manage</b> privileges 
        in the Service Bus service namespace for the service.&nbsp; For more information about 
        creating Access Control rules, please see the <b>
        ManagementService</b> 
        sample from the  <a href="http://acs.codeplex.com/releases/view/57595">Access Control Samples</a>  .</P>
       

    <P xmlns="">The client also authenticates with the Service Bus using a <b>SimpleWebToken </b> 
        credential. It uses the same <CODE>ComputeSimpleWebTokenString(string issuerName, string issuerSecret)</CODE> 
        method to compute the web token string.</P>
    </content>
    </DIV>
        
        
<H2 class=heading>Building and Running the Sample</H2>
<DIV id=sectionSection3 class=section><content 
xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
<P xmlns="">First, build the solution in Visual Studio or from the command line. To 
    run the application, do the following:</P>
<OL class=ordered xmlns="">
  <LI>From a command prompt, run the service (Service\bin\Debug\Service.exe).<BR><BR>
  <LI>When prompted, type the service namespace, the issuer name (e.g. &quot;owner&quot;) and 
      the issuer secret key with which you want the service to run. When 
      authorized, the service indicates that it is listening at the configured 
      address.<BR><BR>
  <LI>From another command prompt, run the client (Client\bin\Debug\Client.exe).<BR><BR>
  <LI>When prompted, type the issuer name (e.g. &quot;owner&quot;), the issuer secret key and the service namespace with which you want the client to 
      connect. Enter a line of text to send to the service, then press <B>Enter</B>.<BR><BR>
  <LI>When finished, press <B>Enter</B> to exit the client and the service.<BR><BR></LI></OL>
<P xmlns=""><B>Expected Output – Service</B></P>
<DIV class=code xmlns=""><SPAN codeLanguage="other">
<TABLE cellSpacing=0 cellPadding=0 width="100%">
  <TBODY>
  <TR>
    <TD colSpan=2><PRE>Your Service Namespace: &lt;service-namespace&gt;
Your Issuer Name: &lt;issuer-name&gt;
Your Issuer Secret: &lt;issuer-secret&gt;
Service address: sb://&lt;service-namespace&gt;.servicebus.windows.net/SimpleWebTokenAuthenticationService/
Press [Enter] to exit
Echoing: a
Echoing: b
Echoing: c</PRE></TD></TR></TBODY></TABLE></SPAN></DIV>
<P xmlns=""><B>Expected Output – Client</B></P>
<DIV class=code xmlns=""><SPAN codeLanguage="other">
<TABLE cellSpacing=0 cellPadding=0 width="100%">
  <TBODY>
  <TR>
    <TD colSpan=2><PRE>Your Service Namespace: &lt;service-namespace&gt;
Your Issuer Name: &lt;issuer-name&gt;
Your Issuer Secret: &lt;issuer-secret&gt;
Enter text to echo (or [Enter] to exit):
a
Server echoed: a
b
Server echoed: b
c
Server echoed: c</PRE></TD></TR></TBODY></TABLE></SPAN></DIV>
</content></DIV>
<!--[if gte IE 5]><tool:tip 
avoidmouse="false" element="languageFilterToolTip"></tool:tip><![endif]--></DIV>
<P xmlns="">
    <hr /> 
    Did you find this information useful?
    <a href="http://go.microsoft.com/fwlink/?LinkID=155664">
        Please send your suggestions and comments about the documentation.

    </a></P></DIV></BODY></HTML>
